package com.jeecms.wicool.manager.product.impl;




import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


import com.jeecms.common.hibernate3.Updater;
import com.jeecms.common.page.Pagination;
import com.jeecms.wicool.dao.product.ProductRelationDao;
import com.jeecms.wicool.entity.product.ProductRelation;
import com.jeecms.wicool.manager.product.ProductRelationMng;

@Service
@Transactional
public class ProductRelationMngImpl implements ProductRelationMng {
	
	private ProductRelationDao dao;
	@Autowired
	public void setDao(ProductRelationDao dao) {
		this.dao = dao;
	}
	
	@Transactional(readOnly = true)
	public Pagination getPage(Integer productId,int pageNo, int pageSize) {
		Pagination page = dao.getPage(productId,pageNo, pageSize);
		return page;
	}
	@Override
	public ProductRelation findById(Integer id) {
		ProductRelation entity = dao.findById(id);
		return entity;
	}

	@Override
	public ProductRelation update(ProductRelation bean) {
		Updater<ProductRelation> updater = new Updater<ProductRelation>(bean);
		bean = dao.updateByUpdater(updater);
		return bean;
	}

	@Override
	public ProductRelation save(ProductRelation bean) {
		dao.save(bean);
		return bean;
	}

	@Override
	public ProductRelation deleteById(Integer id) {
		ProductRelation bean = dao.deleteById(id);
		return bean;
	}
	@Override
	public ProductRelation[] deleteByIds(Integer[] ids) {
		ProductRelation[] beans = new ProductRelation[ids.length];
		for (int i = 0,len = ids.length; i < len; i++) {
			beans[i] = deleteById(ids[i]);
		}
		return beans;
	}
}